<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:disp="http://java.sun.com/jsf/composite/display"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <h:outputStylesheet name="styles/generalStyle.css" />
        <title>#{str.addApplication}</title>
        
        <c:if test="#{jobSeeker.loggedin==false}" >
            <meta http-equiv="REFRESH" content="0;url=../page_login.xhtml"/>
        </c:if>
    </h:head>
    <h:body>
        <c:if test="#{jobSeeker.loggedin==true}" >
        <div id="north">
             <disp:page_north head="#{str.addApplication} #{str.stage} 3" />
        </div>
        <div id="center">
            <h3>#{str.enterDates}</h3>
            <div style="color:red"><h:messages id="validationErrors" /></div>
            <h:form>
                <table>
                    <thead>
                        <tt>
                            <th>#{str.from}</th>
                            <th>#{str.to}</th>
                            <th>#{str.addRemove}</th>
                        </tt>
                    </thead>
                    <tbody>
                        <ui:repeat value="#{jobSeeker.dateAvailabilityList}" var="dateAvailability" varStatus="status">
                            <tr>
                                <td>
                                    #{dateAvailability.startDateString}
                                </td>
                                <td>
                                    #{dateAvailability.endDateString}
                                </td>
                                <td>
                                    <h:commandButton value="#{str.remove}" action="#{jobSeeker.removeDateAvailability(status.index)}">
                                        <f:param name="index" value="#{status.index}" />
                                    </h:commandButton>
                                </td>
                            </tr>
                        </ui:repeat> 
                    </tbody>
                    <tfoot>
                        <tr>
                            <td>
                                <h:selectOneMenu value ="#{jobSeeker.fromYear}">
                                    <f:selectItems value="#{jobSeeker.years}" />
                                </h:selectOneMenu> 
                                <h:selectOneMenu value ="#{jobSeeker.fromMonth}">
                                    <f:selectItems value="#{jobSeeker.months}" />
                                </h:selectOneMenu>     
                                <h:selectOneMenu value ="#{jobSeeker.fromDay}">
                                    <f:selectItems value="#{jobSeeker.dates}" />
                                </h:selectOneMenu>     
                            </td>
                            <td>
                                <h:selectOneMenu value ="#{jobSeeker.toYear}">
                                    <f:selectItems value="#{jobSeeker.years}" />
                                </h:selectOneMenu> 
                                <h:selectOneMenu value ="#{jobSeeker.toMonth}">
                                    <f:selectItems value="#{jobSeeker.months}" />
                                </h:selectOneMenu>     
                                <h:selectOneMenu value ="#{jobSeeker.toDay}">
                                    <f:selectItems value="#{jobSeeker.dates}" />
                                </h:selectOneMenu>   
                            </td>
                            <td>
                                <h:commandButton value="#{str.add}" action="#{jobSeeker.addDateAvailability}" />
                            </td>                            
                        </tr>
                        <tr>
                            <td colspan="2">
                                <h:commandLink action="#{jobSeeker.goToStage(2)}">&lt; #{str.previous}  #{str.stage}</h:commandLink>
                            </td>
                            <td align="right">
                                <h:commandLink action="#{jobSeeker.goToStage(4)}">#{str.next} #{str.stage} &gt;</h:commandLink>
                            </td>
                        </tr>
                    </tfoot>
                </table>
            </h:form>
        </div>
        <div id="south">
            <disp:page_south head="#{str.stage} 3 #{str.of} 4" />
        </div>
            </c:if>
    </h:body>
</html>

